Completed
Push — master ( a5e25e...81f0bb )
by Emil
03:07
created

auth.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1 1
const express = require('express');
2 1
const router = express.Router();
3
4 1
const auth = require("../models/auth.js");
5
6 1
router.get('/api_key', (req, res) => {
7 1
    let data = {
8
        message: "",
9
        email: ""
10
    };
11
12 1
    res.render("api_key/form", data);
13
});
14
15 1
router.post('/api_key/confirmation', (req, res) => {
16 11
    if (req.body.gdpr && req.body.gdpr == "gdpr") {
17 9
        return auth.getNewAPIKey(res, req.body.email);
18
    }
19
20 2
    let data = {
21
        message: "Approve the terms and conditions.",
22
        email: req.body.email
23
    };
24
25 2
    res.render("api_key/form", data);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
26
});
27
28 1
router.get('/api_key/deregister', (req, res) => {
29 1
    let data = {
30
        message: "",
31
        email: "",
32
        apikey: ""
33
    };
34
35 1
    res.render("api_key/deregister", data);
36
});
37
38 1
router.post('/api_key/deregister', (req, res) => {
39 6
    if (req.body.email && req.body.apikey &&
40
        req.body.email.length > 0 && req.body.apikey.length > 0) {
41 1
        return auth.deregister(res, req.body);
42
    }
43
44 2
    let data = {
45
        message: "Both E-mail and API-key is needed to deregister.",
46
        email: "",
47
        apikey: ""
48
    };
49
50 2
    res.render("api_key/deregister", data);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
51
});
52
53 6
router.post('/login', (req, res) => auth.login(res, req.body));
54 5
router.post('/register', (req, res) => auth.register(res, req.body));
55
56
module.exports = router;
57